<template>
  <div class="app-container p-rel">
    <div class="container-title">待办事项</div>
    <form-edit
      class="p-abs"
      :detailForm="detailForm"
      :isEdit="isEdit"
      @submitForm="submitForm"
      :editVisible.sync="editVisible"
      v-if="editVisible"
    ></form-edit>
    <ul class="tabs">
      <li
        v-for="(tab, index) in tabs"
        :key="index"
        :class="{ active: activeIndex === index }"
        @click="selectTab(index)"
      >
        {{ tab }}
      </li>
    </ul>
    <xzch-table v-if="activeIndex == 0"></xzch-table>
    <ysky-table v-if="activeIndex == 1"></ysky-table>
    <yljgjf-table v-if="activeIndex == 2"></yljgjf-table>
    <ysjf-table v-if="activeIndex == 3"></ysjf-table>
    <ylsbba-table v-if="activeIndex == 4"></ylsbba-table>
    <ysglTable v-if="activeIndex == 5"></ysglTable>
    <hsglTable v-if="activeIndex == 6"></hsglTable>
    <!-- todo -->
    <ylfqwTable v-if="activeIndex == 8"></ylfqwTable>
    <xdqxglTable v-if="activeIndex == 9"></xdqxglTable>
    <yfjzglTable v-if="activeIndex == 10"></yfjzglTable>
  </div>
</template>

<script>
/*import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/zhangping/zpEnterpriseInfo";*/
import formEdit from "./editFrom.vue";
import hsglTable from "./hsglTable.vue";
import xdqxglTable from "./xdqxglTable.vue";
import xzchTable from "./xzchTable.vue";
import yfjzglTable from "./yfjzglTable.vue";
import ylfqwTable from "./ylfqwTable.vue";
import yljgjfTable from "./yljgjfTable.vue";
import ylsbbaTable from "./ylsbbaTable.vue";
import ysglTable from "./ysglTable.vue";
import ysjfTable from "./ysjfTable.vue";
import yskyTable from "./yskyTable.vue";
export default {
  name: "Info",
  dicts: [],
  components: {
    formEdit,
    xzchTable,
    yskyTable,
    yljgjfTable,
    ysjfTable,
    ylsbbaTable,
    ysglTable,
    hsglTable,
    ylfqwTable,
    xdqxglTable,
    yfjzglTable,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {},
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      detailForm: {},
      isEdit: false,
      editVisible: false,
      tabs: [
        "行政处罚",
        "医师开药检测",
        "医疗机构记分决定",
        "医师记分决定",
        "医疗机构执业许可证或诊所备案凭证",
        "医师证",
        "护士证",
        "传染病防治",
        "医疗废弃物处置",
        "消毒器械管理",
        "预防接种管理",
      ],
      activeIndex: 0,
    };
  },
  created() {
    this.loading = false;
    //this.getList();
    // this.getCategoryList()
  },
  methods: {
    /** 查询一企一档列表 */
    getList() {
      this.loading = true;
      listInfo(this.queryParams).then((response) => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        enterpriseName: null,
        creditCode: null,
        type: null,
        category: null,
        town: null,
        townCode: null,
        addr: null,
        legalPerson: null,
        contactNumber: null,
        businessLicense: null,
        sanitaryPermit: null,
        sanitaryPermitDate: null,
        healthCertificateStatus: null,
        archivesStatus: null,
        lastUpdateTime: null,
        userId: null,
        createId: null,
        createBy: null,
        createTime: null,
        updateId: null,
        updateBy: null,
        updateTime: null,
        delFlag: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.detailForm = {};
      this.isEdit = false;
      this.editVisible = true;
    },
    /** 修改按钮操作 */
    handleUpdate(row, type) {
      // this.reset();
      const id = row.id || this.ids;
      getInfo(id).then((response) => {
        this.detailForm = response.data;
        if (type == 1) {
          this.isEdit = true;
        } else {
          // 查看
          this.isEdit = false;
        }
        this.editVisible = true;
      });
    },
    /** 提交按钮 */
    submitForm(form, id) {
      if (id != null) {
        updateInfo(form).then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.editVisible = false;
          this.getList();
        });
      } else {
        addInfo(form).then((response) => {
          this.$modal.msgSuccess("新增成功");
          this.editVisible = false;
          this.getList();
        });
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除一企一档编号为"' + ids + '"的数据项？')
        .then(function () {
          return delInfo(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "enterpriseInfo/info/export",
        {
          ...this.queryParams,
        },
        `info_${new Date().getTime()}.xlsx`
      );
    },
    /** 按钮操作 */
    handleTest() {
      //  alert("待做")
    },
    handleInfo(row) {
      //  alert("待做")
    },
    /** tab选中*/
    selectTab(index) {
      this.activeIndex = index;
    },
  },
};
</script>

<style scoped="scoped" lang="scss">
// 清除内外边距
.tabs {
  display: flex;
  list-style-type: none;
  padding: 0;
}

.tabs li {
  cursor: pointer;
  padding-left: 20px;
  padding-right: 20px;
  padding-top: 3px;
  padding-bottom: 3px;
  border: 1px solid #1685fc;
  color: #1685fc;
  border-radius: 2px;
  font-size: 13px;
}

.tabs li.active {
  background-color: #1685fc;
  color: #ffffff;
}
</style>
